-- Prefan Administration Controller
-- Printing Utilities.

-- Variables

PAC.PrintStyles = {}
PAC.TextStart = "[PAC] "

PAC_CHAT = 1
PAC_CONSOLE = 2
PAC_CONSOLE_DEBUG = 3
PAC_CHAT_ALL = 4

local function AddPrint( enum, func ) -- Func args depend on called.

	table.insert( PAC.PrintStyles, {enum = enum, func = func} )
	
end

AddPrint( PAC_CHAT, function( ply, ... )
						PAC.UMStart( "PAC_ChatPrint", ply, Color( 0, 50, 200 ), "[PAC] ", unpack( arg ) )
					end
		)
		
AddPrint( PAC_CHAT_ALL, function( ... )
							for k,v in pairs( player.GetAll() ) do
								PAC.Print( PAC_CHAT, v, unpack( arg ) )
							end
						end
		)
		
AddPrint( PAC_CONSOLE,	function( msg )
								print( PAC.TextStart .. msg )
							end
		)
		
AddPrint( PAC_CONSOLE_DEBUG,	function( msg )
									if PAC.DebugEnabled then print( PAC.TextStart .. msg ) end
								end
		)
		
function PAC.Print( style, ... )

	if style == nil then return end -- Weird bug?

	for k,v in pairs( PAC.PrintStyles ) do
	
		if style == v.enum then
		
			v.func( unpack( arg ) )
			
		end
		
	end
	
end

concommand.Add( "_ChatTest", function( ply, _, args ) PAC.Print( PAC_CHAT, ply, Color( 255, 0, 0 ), "PAC", Color( 0, 255, 0 ), " is very ", Color( 0, 0, 255 ), "amazing!" ) end )

if CLIENT then

	function PAC.ChatPrint( ... )
	
		chat.AddText( unpack( arg ) )
		
	end
	PAC.UMHook( "PAC_ChatPrint", PAC.ChatPrint )
	
end
